﻿using DTcms.Common;
using System.Web.Mvc;

namespace DTcms.Web.Mvc.UI.Page
{
    public partial class tags : BaseController
    {
        protected int id; //调用名
        protected int page; //当前页码
        protected string call_index; //类别别名
        protected string redirect = string.Empty;//回传地址
        protected Model.article_tags model;

        /// <summary>
        /// 重写虚方法,此方法将在Init事件前执行
        /// </summary>
        public tags()
        {
            page = DTRequest.GetQueryInt("page", 1);
            id = DTRequest.GetQueryInt("id");
            call_index = DTRequest.GetQueryString("call_index");

            //如果缓存没有输出，则正常输出页面
            BLL.article_tags bll = new BLL.article_tags();
            if (id > 0)
            {
                model = bll.GetModel(id);
                if (model == null)
                {
                    redirect = linkurl("error", "?msg=" + Utils.UrlEncode("出错啦，您要浏览的页面不存在或已删除！"));
                    return;
                }
            }
            else if (!string.IsNullOrEmpty(call_index))
            {
                model = bll.GetModel(new { call_index = call_index });
                if (model == null)
                {
                    redirect = linkurl("error", "?msg=" + Utils.UrlEncode("出错啦，您要浏览的页面不存在或已删除！"));
                    return;
                }
            }
            else
            {
                model = new Model.article_tags();
                model.title = "所有标签";
            }
            id = model.id;
            //判断SEO标题
            if (string.IsNullOrEmpty(model.seo_title))
            {
                model.seo_title = model.title;
            }
            if (string.IsNullOrEmpty(model.seo_keywords))
            {
                model.seo_keywords = site.seo_keywords;
            }
            if (string.IsNullOrEmpty(model.seo_description))
            {
                model.seo_description = site.seo_description;
            }
        }
    }
}
